<?php
$months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
    "Oct", "Nov", "Dec");
ini_set("date.timezone", "Europe/Paris");
$this_day = now();
$pattern_year = "%Y";
$str_year = mdate($pattern_year, $this_day);

for ($i = 0; $i < 12; $i++) {
    $dropdown_data[$i + 1] = $months[$i];
}
for ($i = 0; $i < 31; $i++) {
    $day_data[$i + 1] = $i + 1;
}
for ($i = $str_year; $i > 1900; $i--) {
    $year_data[$i] = $i;
}
if (isset($error))
    echo $error;
?>
<?php
if ($admin_data->num_rows() > 0) {
    $admin = $admin_data->row();
    
}

$user = $level == 2 ? 'ADMIN' : 'USER';
echo $erreur;
?>
<?php
$image_path = './assets/avatar/images/' . $admin->gravatar;
if ($admin->gravatar != '') {
    if (file_exists($image_path)) {
        $image_path = base_url() . 'assets/avatar/images/' . $admin->gravatar;
    } else {
        $image_path = base_url() . 'assets/noimage.gif';
    }
}  else {
    $image_path = base_url() . 'assets/noimage.gif';
}
?>

<div id="wrapper-content">
<table class="titrepage" width="100%">
        <tr>
            <td> Mon compte </td>
          </tr>
    </table>

        <table id="ajouter" cellpadding="10px" cellspacing="0" >
            <tr>
                <td><a href="<?php echo base_url() . 'index.php/admin/edit_profile' . '/' . $adminid . '/' . $level; ?>">Modifier profile</a></td>
                <?php if ($level == 2) {
                ?>
                    <td><a href="<?php echo base_url() . 'index.php/admin/change_pass' . '/' . $adminid . '/' . $level; ?>">Modifier mot de passe</a></td>
                <?php } ?>
            </tr>
        </table>
        <?php echo form_open_multipart(base_url() . 'index.php/admin/edit_profile' . '/' . $adminid . '/' . $level); ?>
                <table class="list" cellpadding="10px" cellspacing="0" width="100%">
                    <tr>
                        <td>Email:</td>
                        <td><?php echo $admin->email; ?></td>
                    </tr>
                    <tr>
                        <td>Nom d'affichage:</td>
                        <td><?php echo form_error('display_name') ?><br/>
                            <input name="display_name" type="text" value="<?php echo $admin->display_name; ?>"/></td>
                       
                    </tr>
                    <tr>
                        <td>Nom:</td>
                        <td><?php echo form_error('first_name') ?><br/>
                            <input name="first_name" type="text" value="<?php echo $admin->first_name; ?>"/></td>
                    
                    </tr>
                    <tr>
                        <td>Prénom:</td>
                        <td><?php echo form_error('last_name') ?><br/>
                            <input name="last_name" type="text" value="<?php echo $admin->last_name; ?>"/></td>
                      
                    </tr>
                    <tr>
                        <td>Image:</td>
                        <td><img width="150" height="100" src="<?php echo $image_path; ?>"><br/>
                        <input name="userfile" id="userfile" type="file" size="25"/></td>
                  
                    </tr>
                    <tr>
                        <td>Entreprise:</td> <td><input name="company" type="text" value="<?php echo $admin->company; ?>"/></td>
                        <td><?php echo form_error('company') ?><td>
                    </tr>
                    <tr>
                        <td>Sexe</td>
                        <td>
                    <?php
                    $gender = $admin->gender;

                    $male = array(
                        'name' => 'gender',
                        'id' => 'rad_male',
                        'value' => 'm',
                        'checked' => $gender == 'm' ? TRUE : FALSE,
                        'style' => 'margin:10px',
                    );
                    $female = array(
                        'name' => 'gender',
                        'id' => 'rad_female',
                        'value' => 'f',
                        'checked' => $gender == 'f' ? TRUE : FALSE,
                        'style' => 'margin:10px',
                    );

                    echo 'Male' . form_radio($male);
                    echo 'Female' . form_radio($female, 'Female');
                    ?>
                </td>
            </tr>
            <tr>
                <td><label for="birthday">Date de naissance :</label></td>
                <td>
                    D : <?php echo form_dropdown('birth_date', $day_data, get_date_part($str_date, 'day'), 'id="day"'); ?>
                    M : <?php echo form_dropdown('birth_month', $dropdown_data, get_date_part($str_date, 'month'), 'id="month"'); ?>
                    Y : <?php echo form_dropdown('birth_year', $year_data, get_date_part($str_date, 'year'), 'id="year"'); ?>
                </td>
            </tr>
            <tr>
                <td>Téléphone:</td>
                <td><input name="phone" type="text" value="<?php echo $admin->phone; ?>"/></td>
                <td><?php echo form_error('phone') ?><td>
            </tr>
            <tr>
                <td>Mobile:</td>
                <td><input name="mobile" type="text" value="<?php echo $admin->mobile; ?>"/></td>
                <td><?php echo form_error('mobile') ?><td>
            </tr>
            <tr> 
                <td>Adresse:</td> <td><input name="address" type="text" value="<?php echo $admin->address; ?>"/></td>
                <td><?php echo form_error('address') ?><td>
            </tr>
            <tr>
                <td></td><td><input type="submit" name="submit" value=" Enregistrer "/></td>
            </tr>
        </table>
    </div>
    <?php echo form_close() ?>


